package threadtest;

public class Test {
	public static void main(String[] args) {
//		test1();
		test2();
//		test3();
		
	}

	private static void test2() {
		Object o1 = new Object();
		Object o2 = new Object();
		TA a = new TA("aaa",o1,o2);
		TA b = new TA("bbb",o2,o1);
		
		Thread t1 = new Thread(a);
		t1.setName("t1线程");
		Thread t2 = new Thread(b);
		t2.setName("t2线程");
		t1.start();
		try {
			Thread.sleep(100);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		t2.start();
	}

	private static void test3() {
		TC tb = new TC();
		String b = "";
		try {
			b = tb.call();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.err.println(b);
		System.err.println("over");
	}

	private static void test1() {
		Object o1 = new Object();
		Object o2 = new Object();
		Object o3 = new Object();
		TA a = new TA("aaa",o3,o1);
		TA b = new TA("bbb",o1,o2);
		TA c = new TA("ccc",o2,o3);
		
		Thread t1 = new Thread(a);
		Thread t2 = new Thread(b);
		Thread t3 = new Thread(c);
		t1.start();
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		t2.start();
		t3.start();
	}
}
